#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;

void solve()
{
    unordered_map<string, ll> mp1;
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        string a;
        cin >> a;
        mp1[a] = 1;
    }

    ll m;
    double cnt = 0.0;
    cin >> m;
    unordered_map<string, ll> mp2;

    for (ll i = 0; i < m; i++)
    {
        string q;
        cin >> q;
        if (mp1[q])
        {
            cnt += 1;
            cout << "1";
            mp2[q]++;
        }
        else
        {
            cout << "0";
        }
    }
    cout << endl;

    string ans = "None";
    ll maxx = 0;
    for (auto x : mp2)
    {
        if (x.second >= maxx)
        {
            maxx = x.second;
            ans = x.first;
        }
    }

    cout << fixed << setprecision(2) << (cnt / m) * 100 << endl;
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}